# Step 1: Convert to Pandas
pdf = remote_df.toPandas()
# Step 2: Create plot using Plotly
import plotly.express as px
color_map = {
"Remote": 'yellow',
"Hybrid": 'green',
"Onsite": 'blue',
}
fig = px.histogram(
pdf,
x="MAX_YEARS_EXPERIENCE",
y="Average_Salary",
color="REMOTE_GROUP",
color_discrete_map=color_map,
histfunc="avg",
nbins=int(pdf['MAX_YEARS_EXPERIENCE'].max()) + 1,
barmode='group',
title="Average Salary by Years of Experience and Remote Type",
labels={
'MAX_YEARS_EXPERIENCE': 'Max Years of Experience Required',
'Average_Salary': 'Average Salary',
'REMOTE_GROUP': 'Remote Status'
}
)
fig.update_layout(
title_font=dict(family='Garamond', size=24, color='black'),
font=dict(family='Garamond', size=12, color='black'),
legend_title_font=dict(family='Garamond', size=12, color='black'),
legend_font=dict(family='Garamond', size=12, color='black'),
xaxis=dict(dtick=1),
yaxis_title="Average Salary",
bargap=0.2
)
fig.show()